package com.xujl.mvcbind.ui.loading.control;

import android.os.Bundle;
import android.view.View;

import com.xujl.fastlib.base.BaseFragment;
import com.xujl.fastlib.base.IStateLayout;
import com.xujl.mvcbind.R;
import com.xujl.mvcbind.ui.loading.model.LoadingFragmentModel;
import com.xujl.mvcbind.ui.loading.view.LoadingFragmentView;
import com.xujl.task.RxExecutor;
import com.xujl.task.RxHelper;

/**
 * <pre>
 *     author : xujl
 *     e-mail : 597355068@qq.com
 *     time   : 2019/08/20
 *     desc   :
 *     version: 1.0
 * </pre>
 */

public class LoadingFragmentControl extends BaseFragment<LoadingFragmentModel, LoadingFragmentView> {
    @Override
    public void init (Bundle savedInstanceState) {

    }

    @Override
    public void onClick (View view) {
        super.onClick(view);
        switch (view.getId()) {
            case R.id.btn_loading_window:
                mView.showLoadingWindow();
                RxExecutor.getInstance()
                        .executeTask(new RxHelper.DelayTask(1500) {
                            @Override
                            public void timeOver () {
                                mView.dismissLoadingWindow();
                            }
                        });
                break;
            case R.id.btn_loading_layout:
                mView.showState(IStateLayout.TYPE_LOADING);
                RxExecutor.getInstance()
                        .executeTask(new RxHelper.DelayTask(1500) {
                            @Override
                            public void timeOver () {
                                mView.showState(IStateLayout.TYPE_SUCCESS);
                            }
                        });
                break;
            case R.id.btn_empty_layout:
                mView.showState(IStateLayout.TYPE_EMPTY);
                RxExecutor.getInstance()
                        .executeTask(new RxHelper.DelayTask(1500) {
                            @Override
                            public void timeOver () {
                                mView.showState(IStateLayout.TYPE_SUCCESS);
                            }
                        });
                break;
            case R.id.btn_error_layout:
                mView.showState(IStateLayout.TYPE_ERROR);
                RxExecutor.getInstance()
                        .executeTask(new RxHelper.DelayTask(1500) {
                            @Override
                            public void timeOver () {
                                mView.showState(IStateLayout.TYPE_SUCCESS);
                            }
                        });
                break;
            default:

                break;

        }
    }
}
